<!DOCTYPE html>

<html>

<head>
  <meta charset="utf-8">
  <title>{$config}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="referrer" content="no-referrer" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__PUBLIC__/common/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/admin/css/admin.min.css" media="all">
</head>
<style type="text/css">
   .wrapper {position: relative;}
   #input {position: absolute;top: 0;left: 0;opacity: 0;z-index: -10;}
</style>
<body>

  <div class="layui-fluid">

    <div class="layui-row layui-col-space1">
      <div class="layui-col-md12">

          <div class="layui-card">
            <div class="layui-card-header">
           列表
            </div>
              <div class="layui-card-body">



              <form action="__MODULE__/Reso/search" method="POST">
                  <div class="layui-inline">
                      <label class="layui-form-label">电影名字</label>
                      <div class="layui-input-block">
                          <input type="text" name="keyword" autocomplete="off" class="layui-input" />
                      </div>
                  </div>

                  <div class="layui-inline">
                      <button class="layui-btn layuiadmin-btn-admin" lay-submit="" lay-filter="card-table-list-search">
                          <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                      </button>
                  </div>
              </form>
              </div>

          </div>
      </div>

    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body">
          <div style="padding-bottom: 10px;" class="layui-btn-group">

          <a class="layui-btn layuiadmin-btn-admin" href="__URL__/add">添加</a>
        </div>

          <table id="sms-plugin-table" lay-filter="sms-plugin-table"></table>
           <table id="list-table" class="layui-table">
                <thead>
                    <tr>

                        <th width="10">
                            ID
                        </th>
                        <th >
                           标题
                        </th>
						<th width="40px">
                          解锁类型
                        </th>
                        <th width="120px">图片</th>
                        <th width="340">资源地址（双击可更改）</th>
						<th width="10px">发现推荐</th>
						<th width="10px">是否显示</th>

						<th width="20px">添加时间</th>

                        <th width="50">
                            操作
                        </th>
                        <th width="120px">前端连接</th>
                    </tr>
                </thead>
				 <volist name="mod" id="vo">
                <tbody>
                    <tr>

                        <td>
                          {$vo.id}
                        </td>
                        <td>
                           {$vo.title}
                        </td>
						 <td>
                           <if condition="$vo.type == 1 ">
						   广告解锁获取
						   </if>
						   <if condition="$vo.type == 2 ">
						   广告解锁看全文
						   </if>
						   <if condition="$vo.type == 3 ">
						   VIP专享
						   </if>
						   <if condition="$vo.type == 4 ">
						   积分购买
						   </if>
						   <if condition="$vo.type == 5 ">
						   免费获取
						   </if>
                        </td>
						<td>
						 <div><img referrer="no-referrer" src="{$vo.picname}" /> </div>
						</td>

						<td id="{$vo.id}">
                            {$vo.dizhi}
                        </td>

						 <if condition="$vo.hot == 1 ">
						<td class=""><a href="__URL__/guan1?id={$vo.id}">
						<button class="layui-btn">显示</button> </a>

						</td>
						<else/>
						<td class=""><a href="__URL__/tans1?id={$vo.id}">
						<button class="layui-btn layui-bg-gray">隐藏</button> </a>

						</td>
						 </if>
						 <if condition="$vo.status == 1 ">
						<td class=""><a href="__URL__/guan?id={$vo.id}">
						<button class="layui-btn layui-bg-red">显示</button> </a>

						</td>
						<else/>
						<td class=""><a href="__URL__/tans?id={$vo.id}">
						<button class="layui-btn layui-bg-gray">隐藏</button> </a>

						</td>
						 </if>
						<td >{$vo.addtime|date="Y-m-d H:i",###}</td>

                        <td class="td-manage">

                            <a title="编辑" href="__URL__/edit?id={$vo.id}"
                            class="ml-5" style="text-decoration:none">
                                <i class="layui-icon">&#xe642;</i>编辑
                            </a>

                            <a title="删除" href='javascript:confirm_del("{$vo.id}")'
                            style="text-decoration:none">
                                <i class="layui-icon">&#xe640;</i>删除
                            </a>
                        </td>

                        <td>
                            <a id="text"> /pages/details/details?tid={$vo.id} </a>
                            <textarea id="input">这是幕后黑手</textarea>
                            <button class="layui-btn layui-btn-normal layui-btn-radius" onclick="copyText()">复制</button>
                        </td>
                    </tr>
                </tbody>
				</volist>
            </table>

            <div id="page">{$pageinfo}</div>

        </div>
      </div>
    </div>
  </div>

<style>
    #page > div{
        margin: 35px 0 15px 0;
    }
    #page >div> span{
        background-color: #4e6ef2;
        border: 1px #4e6ef2 solid;
        border-radius:5px;
        color: #ffffff;
        margin: 5px;
        padding: 5px 10px;
    }
    #page > div > a{
        border-radius:5px;
        border: 1px #4e6ef2 solid;
        color: #4e6ef2;
        margin: 5px;
        padding: 5px 10px;
    }
</style>
<script src="__PUBLIC__/common/lib/layui/layui.js"></script>
 <script type="text/javascript" src="__PUBLIC__/common/lib/jquery/jquery-3.3.1.min.js"></script>
 <script type="text/javascript" src="__PUBLIC__/common/lib/jquery/jquery.cookie.js"></script>
 <script src="__PUBLIC__/js/jquery-1.9.1.min.js"></script>

<script>
layui.use(['laypage', 'layer'], function(){
  var laypage = layui.laypage
  ,layer = layui.layer;

  //不显示首页尾页
  laypage.render({
    elem: 'demo4'
    ,count: 100
    ,first: false
    ,last: false
  });
 });
function copyText() {
      var text = document.getElementById("text").innerText;
      var input = document.getElementById("input");
      input.value = text; // 修改文本框的内容
      input.select(); // 选中文本
      document.execCommand("copy"); // 执行浏览器复制命令
      alert("复制成功");
    }

    function confirm_del(id){
        layer.confirm('是否删除?',function () {
                var url = '__URL__/del?id='+id+'&url=__URL__'
                var gotoLink = document.createElement('a');
                gotoLink.href = url;
                document.body.appendChild(gotoLink);
                gotoLink.click();
            }
        )
    }

$("#list-table").on("dblclick","td",function(){
    var td = $(this);
    var id = td.attr("id");
    if(typeof id === "undefined"){
        return false
    }
    // 根据表格文本创建文本框 并加入表表中--文本框的样式自己调整
    var text = td.text();

    // 去除空格
    text = $.trim(text)
    var txt = $("<textarea  name=\"dizhi\" rows=\"4\" cols='15'  class=\"layui-textarea\" ></textarea>").val(text);
    txt.blur(function(){
        // 失去焦点，保存值。于服务器交互自己再写,最好ajax
        var newText = $(this).val(),
            input=$(this),
            data={'dizhi':newText,'id':id};
        const  url = '/Youni/Reso/editDizhi'
        $.post(url,data,function (e) {
            layer.msg(JSON.parse(e).msg)
            // 移除文本框,显示新值
            input.remove();
            td.text(newText);
        });
    });
    td.text("");
    td.append(txt);
});

</script>
</body>
</html>
